import etEncryption from '../util/etEncryption'
export default {
  states: {
    usphone: ''
  },
  mutations: {
    // 设置用户手机号
    setUsPhone (state, data) {
      if (data.phone) {
        let nickphone = ''
        try {
          nickphone = etEncryption.encryption(data.phone)
        } catch (e) {
          nickphone = 'err'
        }
        window.zhuge.identify(nickphone)
      }
    },
    zhugeMsg (state, data) {
      window.zhuge.track(data.zhugetitle, data.zhugecontext)
    }
  },
  actions: {
    // 设置用户手机号
    setUsPhone (context, data) {
      context.commit('setUsPhone', data)
    },
    // 好友页
    zhugeFriend (context, data) {
      let zhugeData = {
        zhugetitle: 'S-进入好友',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 礼品商城
    zhugeMall (context, data) {
      let zhugeData = {
        zhugetitle: 'S-进入商城',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 小E成长首页
    zhugeE (context, data) {
      let zhugeData = {
        zhugetitle: 'S-进入小E',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 首页小广告
    zhugeAd (context, data) {
      let zhugeData = {
        zhugetitle: 'S-进入活动条',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 小E介绍按钮
    zhugeIntroduce (context, data) {
      let zhugeData = {
        zhugetitle: 'S-小E介绍按钮',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 兑换记录
    zhugeCommodityOrder (context, data) {
      let zhugeData = {
        zhugetitle: 'S-进入兑换记录',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 商品详情
    zhugeGiftDetails (context, data) {
      let zhugeData = {
        zhugetitle: 'S-进入商品详情',
        goodsId: data.gid,
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 成长规则
    zhugeGrowRule (context, data) {
      let zhugeData = {
        zhugetitle: 'S-进入成长规则',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 小e成长故事页
    zhugeGrowthStory (context, data) {
      let zhugeData = {
        zhugetitle: 'S-进入小e成长故事页',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 首页长图广告
    zhugeImgListAd (context, data) {
      let zhugeData = {
        zhugetitle: 'S-首页长图广告',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 长图广告我感兴趣
    zhugeImgListAdLike (context, data) {
      let zhugeData = {
        zhugetitle: 'S-长图广告我感兴趣',
        zhugecontext: {
          '手机号': data.phone,
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 数据记录信息
    zhugeRecordInfo (context, data) {
      let typeName = data.typeId === 0 ? '我的星星' : data.typeId === 1 ? '我的等级' : '我的礼券'
      let zhugeData = {
        zhugetitle: 'S-数据记录信息',
        zhugecontext: {
          '渠道': 'APPHybird',
          '数据类型': typeName
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 微信分享规则
    zhugeWxshareDetails (context, data) {
      let zhugeData = {
        zhugetitle: 'S-进入小E成长微信分享规则',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 微信分享好友,排名
    zhugeWxshareFriends (context, data) {
      let zhugeData = {
        zhugetitle: 'W-微信分享好友-排名',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 微信分享朋友圈排名,排名
    zhugeWxshareFriendsQuan (context, data) {
      let zhugeData = {
        zhugetitle: 'W-微信分享朋友圈-排名',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 微信分享好友,答题
    zhugeWxshareFriendsAnswer (context, data) {
      let zhugeData = {
        zhugetitle: 'W-微信分享好友-答题',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 微信分享朋友圈排名,答题
    zhugeWxshareFriendsQuanAnswer (context, data) {
      let zhugeData = {
        zhugetitle: 'W-微信分享朋友圈-答题',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 通过h5登陆
    zhugeLoginByH5 (context, data) {
      let zhugeData = {
        zhugetitle: 'W-通过H5登陆',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 通过h5登陆
    zhugeSignUpByH5 (context, data) {
      let zhugeData = {
        zhugetitle: 'W-通过H5注册',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    },
    // 扫描或者分享链接进入
    zhugeInByshare (context, data) {
      let zhugeData = {
        zhugetitle: 'W-通过扫描或者分享链接进入',
        zhugecontext: {
          '渠道': 'APPHybird'
        }
      }
      context.commit('zhugeMsg', zhugeData)
    }
  },
  getters: {}
}
